package Day009_Map_斗地主_冒泡排序.demo06_集合嵌套;

import java.util.*;

public class d2_List嵌套Map {
    public static void main(String[] args) {

        //第一个班：
        Map<String, String> map1 = new HashMap<>();
        map1.put("it001", "迪丽热巴");
        map1.put("it002", "古力娜扎");

        //第二个班：
        Map<String, String> map2 = new HashMap<>();
        map2.put("heima001", "蔡徐坤");
        map2.put("heima002", "李易峰");

        //将两个班的map存储到一个ArrayList中
        List<Map<String, String>> list = new ArrayList<>();
        list.add(map1);
        list.add(map2);
        System.out.println(list.size()); // 2

        //遍历list，取出每个Map
        for (Map<String, String> map : list) {

        //遍历map
            //得到所有的键,存入Set集合
            Set<String> keys = map.keySet();
            for (String key : keys) {
                //根据键获取对应的值
                String value = map.get(key);
                System.out.println(key + " - " + value);
            }
        }
    }
}

